<?php
class Cars
{
	private $_yaht;
	private $_pict;
	
	public function __construct()
	{
		$this->_yaht = new Zend_Db_Table('cars');
	}
	
	public function getList($Quantity = 0)
	{
		$SelectYaht = $this->_yaht->select()->order('Name');
		
		if ($Quantity>0) $SelectYaht = $SelectYaht->limit($Quantity);

		$Rows = $this->_yaht->fetchAll($SelectYaht);
		
		return $Rows->toArray();
	}
	
	
   
	
    public function getOne($YID)
    {
        $Yaht = $this->_yaht->find($YID);
        if ($Yaht)
        {
        	$arrYaht = $Yaht->current();
        	if (!$arrYaht) return false;
        	$arrYaht  = $arrYaht->toArray();
        
        	return $arrYaht;
        }
        else
        {
        	return false;
        }
    }
    
    
   
    
    public function save($YID,$Params)
    {
    	$Yaht = $this->_yaht->update($Params, 'id = ' . intval($YID));
    }
    
    public function delete($YID)
    {
        $Yaht = $this->_yaht->delete('id = ' . intval($YID));
    }
    
    
    public function create()
    {
        $data = array(
                    'Name'        => 'Новый объект',
                    'Description' => ''
        );
    	$Yaht = $this->_yaht->createRow($data);
    	$Yaht->save();
    	return $Yaht->id; 
    }
    
}